import React from 'react'
import RequireAuth from '../utils/RequiredAuth'
import type { RouteObject } from 'react-router-dom'

const Home = React.lazy(() => import('../page/home'))
const Login = React.lazy(() => import('../page/login'))
const NotFound = React.lazy(() => import('../page/404'))

const routes: Array<RouteObject> = [
  {
    path: '/',
    element: (
      <RequireAuth allow={true} redirectTo="/login">
        <Home />
      </RequireAuth>
    ),
  },
  {
    path: '/login',
    element: (
      <RequireAuth allow={false} redirectTo="/">
        {' '}
        <Login />
      </RequireAuth>
    ),
  },
  {
    path: '*',
    element: <NotFound />,
  },
]

export { routes }
